package cn.wolfcode.car.business.query;

import cn.wolfcode.car.common.base.query.QueryObject;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Calendar;
import java.util.Date;

@Setter@Getter
public class BusCustomerQuery extends QueryObject {
    private String name;
    private Integer vip;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date startTime;
    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date endTime;



    public Date getEndTime(){
        if (endTime == null) {
            return null;
        }
        //将日期变成当天的23:59:59
        Calendar calendar = Calendar.getInstance();
        calendar.setTime(endTime);
        //加一天
        calendar.add(Calendar.DAY_OF_YEAR,1);
        //在减去一秒
        calendar.add(Calendar.SECOND,-1);
        return calendar.getTime();
    }
}
